package com.css.fxfzypg.modules.baseData.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.css.fxfzypg.constants.YNEnum;
import com.css.fxfzypg.modules.baseData.entity.AnrrsmEntity;
import com.css.fxfzypg.modules.baseData.queryParams.AnrrsmQueryParams;
import com.css.fxfzypg.modules.baseData.repository.AnrrsmRepository;
import com.css.fxfzypg.modules.baseData.service.AnrrsmService;
import com.css.fxfzypg.util.PlatformDateUtils;
import com.css.fxfzypg.util.PlatformPageUtils;
import com.css.fxfzypg.util.UUIDGenerator;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;

/**
 * @author y1fan
 * @create 2022-08-29 15:22
 */
@Service
public class AnrrsmServiceImpl implements AnrrsmService {


    @Resource
    private AnrrsmRepository anrrsmRepository;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public AnrrsmEntity saveAnrrsm(AnrrsmEntity anrrsmEntity) {
        anrrsmEntity.setArrsmId(UUIDGenerator.getUUID());
        anrrsmEntity.setArrsmCreatetime(PlatformDateUtils.getCurrentTimestamp());
        anrrsmEntity.setArrsmIsdelete(YNEnum.Y.toString());
        return anrrsmRepository.saveAnrrsm(anrrsmEntity);
    }

    @Override
    public Object getAnrrsmById(String id) {
        return anrrsmRepository.getAnrrsmById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public AnrrsmEntity updateAnrrsm(AnrrsmEntity anrrsmEntity) {
        anrrsmEntity.setArrsmUpdatetime(PlatformDateUtils.getCurrentTimestamp());

        return anrrsmRepository.updateAnrrsm(anrrsmEntity);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteAnrrsm(List<String> ids) {
        Timestamp currentTimestamp = PlatformDateUtils.getCurrentTimestamp();
        anrrsmRepository.deleteAnrrsm(ids,currentTimestamp);
    }

    @Override
    public Map<String,Object> getAllAnrrsmByParams(AnrrsmQueryParams queryParams) {
        return anrrsmRepository.getAllAnrrsmByParams(queryParams);

    }

  /*  @Override
    public void exportExcel(HttpServletResponse response) throws IOException {

    }

    @Override
    public void importExcel(MultipartFile file) throws IOException {

    }*/
}
